package com.zl.service;

import com.zl.beans.MeetRoom;
import com.zl.beans.Page;
import com.zl.dao.MeetRoomDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MeetRoomServiceImpl implements MeetRoomService {
    @Autowired
    private MeetRoomDao roomDao;
    @Override
    public Page<MeetRoom> findRoom(int pagenum) {
        Page<MeetRoom> page = new Page();
        page.setPagenum(pagenum);
        int totalRows = roomDao.findRows();
        page.setTotalRows(totalRows);
        List<MeetRoom> datas = roomDao.selectRooms(page);
        page.setDatas(datas);
        return page;
    }

    @Override
    public Page<MeetRoom> findRoomByName(String name) {
        Page<MeetRoom> page = new Page();
        List<MeetRoom> data = roomDao.selectRoomsByName(name);
        page.setDatas(data);
        return page;
    }

    @Override
    public void addRoom(String roomName, String roomContent) {
        roomDao.insertRoom(roomName,roomContent);
    }

    @Override
    public void changeRoom(String roomName, String roomContent,int id) {
        roomDao.updataRoom(roomName,roomContent,id);
    }

    @Override
    public MeetRoom selectById(Integer id) {
        MeetRoom room = roomDao.findRoomById(id);
        return room;
    }

    @Override
    public void rmRoom(Integer id) {
        roomDao.delectRoomById(id);
    }

}
